using Firestarter.DB.Schema.BO;
using Firestarter.DB.Schema.Logic;

namespace FireStarterModeller.Test
{
    public class DbViewBuilder
    {
        private readonly DBView _dbView;

        public DbViewBuilder(DBView dbView)
        {
            _dbView = dbView;
        }

        public DBView View
        {
            get { return _dbView; }
        }

        private DBViewColumn AddColumnOfIdType(string columnName)
        {
            return AddColumn(columnName, DBDataTypes.UNIQUEIDENTIFIER, 0);
        }

        public DBViewColumn AddColumn(string columnName)
        {
            return AddColumn(columnName, DBDataTypes.VARCHAR, 50);
        }

        public DBViewColumn AddColumn(string columnName, string dataType, int dataLength)
        {
            DBViewColumn dbViewColumn = new DBViewColumn(columnName)
                                    {
                                        DataType =  dataType,
                                        DataLength = dataLength,
                                        Nullable = true
                                    };
            _dbView.Columns.Add(dbViewColumn);
            dbViewColumn.OrdinalPosition = _dbView.Columns.Count;
            return dbViewColumn;
        }
    }
}